;
var user_login_ops = {
    init: function () {
        this.eventBind();
    },
    eventBind: function () {
        $('.do_login').click(function (ev) {
            ev.preventDefault();

            var btn_target = $(this);

            if (btn_target.hasClass('disabled')) {
                common_ops.alert('正在处理，请不要重复提交!');
                return;
            }

            var login_name = $('.login_wrap input[name=login_name]').val();
            var login_pwd = $('.login_wrap input[name=login_pwd]').val();
            if (login_name == undefined || login_pwd == undefined || login_name.length < 1 || login_pwd.length < 1) {
                common_ops.alert('账号或密码错误，请重试');
                return;
            }
            btn_target.addClass('disabled');
            $.ajax({
                url: common_ops.buildUrl('/user/login'),
                type: 'POST',
                data: {
                    'login_name': login_name,
                    'login_pwd': login_pwd
                },
                dataType: 'json',
                success: function (data) {
                    btn_target.removeClass('disabled');
                    var callback = null;
                    if (data['code'] == 200) {
                        callback = function () {
                            window.location.href = '/';
                        };

                        common_ops.alert(data['msg'], callback);
                    }
                    else {
                        common_ops.alert(data['msg'])
                    }
                },
                fail: function () {
                    btn_target.removeClass('disabled');
                    common_ops.alert('数据提示失败，请重试！');
                }
            });
        });
    }
};

$(function () {
    user_login_ops.init();
});